package com.student.foodAfter.controller;

import com.student.foodAfter.common.aop.OperLog;
import com.student.foodAfter.utils.Result;
import com.student.foodAfter.service.FoodService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("food")
public class FoodController {
    @Resource
    private FoodService foodService;

    //查询菜品
    @GetMapping("/getCategoryFood/{category}")
    @OperLog(operModul = "菜品模块",operType = "查询",operDesc = "显示对应的菜品")
    public Result getCategoryFood(@PathVariable String category){
        Result food = foodService.getCategoryFood(category);
        return food;
    }
    //查询功能
    @GetMapping("/getCategory/{foodname}")
    @OperLog(operModul = "菜品模块",operType = "查询",operDesc = "查询对应的菜品")
    public Result getCategory(@PathVariable String foodname){
        String category = foodService.getCategory(foodname);
        if(category.equals("没有查询到"))
            return Result.fail("本店没有这个菜品");
        else
            return Result.success(category);
    }
}
